package models

import (
	"gorm.io/gorm"
	"time"
)

type BlogArticles struct {
	ID            int        `gorm:"primary_key" json:"id"`
	PublisherID   int        `gorm:"column:publisher_id" json:"-"`
	BlogTitle     string     `gorm:"column:blog_title" json:"title"`
	PublisherName string     `gorm:"-" json:"publisher"`
	TagList       []string   `gorm:"-" json:"tag_list"`
	Tags          []BlogTags `json:"-" gorm:"-"`
	Tag           []Tage     `json:"-" gorm:"-"`
	BlogType      BlogTypes  `json:"-" gorm:"-"`
	TypeName      string     `gorm:"-" json:"type"`
	TypeID        int        `gorm:"column:type_id" json:"-"`
	PublisherTime string     `json:"pub_at" gorm:"-"`
	BlogText      string     `json:"blog" gorm:"column:blog_text"`
	CreateAt      time.Time  `json:"-"`
	UpdateAt      time.Time  `json:"-"`
}

func (*BlogArticles) TableName() string {
	return "blog_articles"
}

type BlogTags struct {
	gorm.Model
	BlogID int `gorm:"column:blog_id" json:"-"`
	TageID int `gorm:"column:tage_id" json:"-"`
}

func (*BlogTags) TableName() string {
	return "blog_tags"
}

type Tage struct {
	ID        int       `gorm:"primary_key"`
	TagName   string    `gorm:"column:tag_name" json:"tag_name"`
	CreatedAt time.Time `json:"-" gorm:"column:create_at"`
	UpdatedAt time.Time `json:"-" gorm:"column:update_at"`
}

type BlogTypes struct {
	ID         int       `gorm:"primary_key" json:"id"`
	TypeName   string    `gorm:"column:type_name" json:"pub_type"`
	CreateTime string    `json:"create_time" gorm:"-"`
	CreatedAt  time.Time `json:"-" gorm:"column:create_at"`
	UpdatedAt  time.Time `json:"-" gorm:"column:update_at"`
}

func (*BlogTypes) TableName() string {
	return "blog_types"
}
